/*----------------------------------------------------*
       Project : Covid 19
       Purpose : Figure 1 and Table 2
       Updated : June 12 2020   16:53 IST
*-----------------------------------------------------*/

*=======================================================================*


** checking if additional packages have been installed.
/*
foreach package in blindschemes coefplot {
     capture which `package'
     if _rc==111 ssc install `package'
}
*/
** SETTING UP
version 15
clear all
pause on
set more off
qui cap log c

set scheme plotplain // setting the scheme we use in the paper, user may use any scheme they prefer


loc path_LM = "/Users/louis-maeljean/Dropbox (MIT)/West Bengal Information Campaign/AER_I/for_submission"
loc path = "`path_LM'" 		//other users should change this

cd "`path'"



*========================================================================*

/*PLEASE READ:
In this file we implement Table 2: The Main GP Survey Regression Table.
We run three sets of regressions for each outcome in this file:
	1. Pooled
	2. Only Jio Users
	3. Only Non-Jio Users


DEFINITIONS FOR EACH OF THE VARIABLES USED BELOW:
	1. travel_own  =  Whether the respondent traveled outside own village in the past 2 days (its a binary : 1 or 0)
	2. W2total_interactions_vill  =  Total Interaction in past two days (summing within village, vill-vill, vill-town and vill-city) - winsorized top 5%
	3. resp_mask_wear  =  Does the respondent wear a mask or cover face when leaving house (its a binary : 1 or 0 ).
  4. comm_mask_rate  = Respondent's answer to: Out of 100 people in your village, how many people are wearing masks?
	5. typical_handwash  =  If someone in their village comes back home 10 times a day, then out of 10 times how many times do they wash their hands with soap.
	6. W2ever_talk  =  Per day count of how many people did the respondent give or get info/advise about COVID19  - winsorized top 5%
	7. net_knowledge =  ( (#right symptoms + #right precautions) - (#wrong symptoms + #wrong precautions )  note : read '#' as 'number of'.


We use the following FE and controls throughout:
	1. district FE = District respondent lived in
	2. id_date FE  = Survey date (survey lasted for a total of 9 days)
	3. jio_yn      = Does respondent or someone in their HH have a jio cellular connection
	4. resp_age    = Age of the respondent
	5. resp_gender = Gender of the respondent
	6. smartphone  = Does the respondent or someone in their HH have a smartphone

Finally, throughout all the regressions we cluster standard errors at the PIN code level.

*/


** LOADING PROCESSED DATASET **
use "`path'/data/outcomes_reg_input.dta", clear   // look at 01_processing for how this was generated
label var TrtXjio "Treat(Jio) = Treat(Non-Jio)"
local controls smartphone resp_age resp_gender  //these controls will be added to all the regressions below


*=================================================================
                    * Table 2| Phone Survey Regression *
*=================================================================


*************************************************************************************
*
* The code for Table 2 is organized as follows:
* For each of the three samples pooled, jio, non-jio:
*	Run the regressions once to get the q-values and store them in a separate frame
*	Run the regressions a second time to get the actual regression tables
*	Run the regressions a third tim to perform an F-test using suest
*	
*
*************************************************************************************

**** PANEL A : POOLED SAMPLE ****

//Q-values
frame create MHT		//create temporary frame to store q_values
frame change MHT
	use "`path'/data/outcomes_reg_input.dta", clear 
	local controls smartphone resp_age resp_gender

	//regressions
	postfile q_values2 p_val using Q_valuesGP, replace //create .dta file named Q_valuesGP where p_values will be stored (p_val) to perform multiple hypothesis testing on treatment coefficients
	quietly reg travel_own Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg W2total_interactions_vill  Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg typical_handwash Treatment i.district i.id_date i.jio_yn `controls', vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg resp_mask_wear Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg W2ever_talk Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg net_knowledge Treatment i.district i.id_date i.jio_yn `controls', vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	postclose q_values2

	use Q_valuesGP, clear 	//open Q_values_tab1 to compute q_values
	qqvalue p_val, method(simes) qvalue(q) //compute q_values using Simes correction (equiv. BH)
	   
	//q_values
	loc travel_qval : display %4.3f q[1]
	loc intrct_qval : display %4.3f q[2]
	loc handwash_qval : display %4.3f q[3]
	loc mask_qval : display %4.3f q[4]
	loc talk_qval : display %4.3f q[5]
	loc knowledge_qval : display %4.3f q[6]
	
	

frame change default 		//back to default frame

//Main Regressions
reg travel_own Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
su travel_own if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_pooled.tex", ///
keep(Treatment) replace ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`travel_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark"\ "Jio FE", "\checkmark" \ "Control Mean", "`depvarmean'") ctitles("Variables","Did you travel outside your village?") statfont(normalsize) summstat(N)  summtitles("Observations")


reg W2total_interactions_vill  Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
su W2total_interactions_vill if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_pooled.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons sdec(3) nostars nolegend addrows("q-value", "`intrct_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark"\ "Jio FE", "\checkmark" \ "Control Mean", "`depvarmean'") ctitles("Variables","Number of interactions with people within 2 arms length") statfont(normalsize) summstat(N)  summtitles("Observations")


reg typical_handwash Treatment i.district i.id_date i.jio_yn `controls', vce(cluster pincode)
su typical_handwash if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_pooled.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`handwash_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark"\ "Jio FE", "\checkmark" \ "Control Mean", "`depvarmean'" ) ctitles("Variables","Estimated \% time washing hands upon returning home") statfont(normalsize) summstat(N)  summtitles("Observations")

reg resp_mask_wear Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
su resp_mask_wear if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_pooled.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons sdec(3) nostars nolegend addrows("q-value", "`mask_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark"\ "Jio FE", "\checkmark" \ "Control Mean", "`depvarmean'") ctitles("Variables","Did you use a mask?") statfont(normalsize) summstat(N)  summtitles("Observations")


reg W2ever_talk Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
su W2ever_talk if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_pooled.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`talk_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark"\ "Jio FE", "\checkmark" \ "Control Mean", "`depvarmean'" ) ctitles("Variables","Number of conversations in person /online /mobile about COVID-19") statfont(normalsize) summstat(N)  summtitles("Observations")

reg net_knowledge Treatment i.district i.id_date i.jio_yn `controls', vce(cluster pincode)
su net_knowledge if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_pooled.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`knowledge_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark"\ "Jio FE", "\checkmark" \ "Control Mean", "`depvarmean'" ) ctitles("Variables","COVID-19 Knowledge Index") statfont(normalsize) summstat(N)  summtitles("Observations")


frame drop MHT

**** PANEL B : JIO SAMPLE ****
preserve

keep if jio_yn == 1


//Q-values
frame create MHT
frame change MHT
	use "`path'/data/outcomes_reg_input.dta", clear 
	local controls smartphone resp_age resp_gender
	keep if jio_yn == 1

	postfile q_values2 p_val using Q_valuesGP, replace //create .dta file named Q_valuesGP where p_values will be stored (p_val) to perform multiple hypothesis testing on treatment coefficients
	quietly reg travel_own Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg W2total_interactions_vill  Treatment i.district i.id_date `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg typical_handwash Treatment i.district i.id_date  `controls', vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg resp_mask_wear Treatment i.district i.id_date `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg W2ever_talk Treatment i.district i.id_date  `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg net_knowledge Treatment i.district i.id_date  `controls', vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	postclose q_values2

	use Q_valuesGP, clear 	//open Q_values_tab1 to compute q_values
	qqvalue p_val, method(simes) qvalue(q) //compute q_values using Simes correction (equi. BH)
	   
	//Pooled q_values
	loc travel_qval : display %4.3f q[1]
	loc intrct_qval : display %4.3f q[2]
	loc handwash_qval : display %4.3f q[3]
	loc mask_qval : display %4.3f q[4]
	loc talk_qval : display %4.3f q[5]
	loc knowledge_qval : display %4.3f q[6]
	
	
frame change default 		//back to default frame
	


//Main Regressions
reg travel_own Treatment i.district i.id_date `controls' , vce(cluster pincode)
su travel_own if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_jio.tex", ///
keep(Treatment) replace ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`travel_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \ "Control Mean", "`depvarmean'" ) ctitles("Variables","Did you travel outside your village?") statfont(normalsize) summstat(N)  summtitles("Observations")


reg W2total_interactions_vill  Treatment i.district i.id_date  `controls' , vce(cluster pincode)
su W2total_interactions_vill if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_jio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons sdec(3) nostars nolegend addrows("q-value", "`intrct_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \ "Control Mean", "`depvarmean'" ) ctitles("Variables","Number of interactions with people within 2 arms length") statfont(normalsize) summstat(N)  summtitles("Observations")


reg typical_handwash Treatment i.district i.id_date `controls', vce(cluster pincode)
su typical_handwash if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_jio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`handwash_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \ "Control Mean", "`depvarmean'" ) ctitles("Variables","Estimated \% time washing hands upon returning home") statfont(normalsize) summstat(N)  summtitles("Observations")

reg resp_mask_wear Treatment i.district i.id_date  `controls' , vce(cluster pincode)
su resp_mask_wear if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_jio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons sdec(3) nostars nolegend addrows("q-value", "`mask_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \ "Control Mean", "`depvarmean'") ctitles("Variables","Did you use a mask?") statfont(normalsize) summstat(N)  summtitles("Observations")


reg W2ever_talk Treatment i.district i.id_date  `controls' , vce(cluster pincode)
su W2ever_talk if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_jio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`talk_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'") ctitles("Variables","Number of conversations in person /online /mobile about COVID-19") statfont(normalsize) summstat(N)  summtitles("Observations")

reg net_knowledge Treatment i.district i.id_date `controls', vce(cluster pincode)
su net_knowledge if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_jio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`knowledge_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" )  ctitles("Variables","COVID-19 Knowledge Index") statfont(normalsize) summstat(N)  summtitles("Observations")


restore


frame drop MHT

**** PANEL C : NON JIO SAMPLE ****
preserve

keep if jio_yn == 0



//Q-values
frame create MHT
frame change MHT
	use "`path'/data/outcomes_reg_input.dta", clear 
	local controls smartphone resp_age resp_gender
	keep if jio_yn == 0

	postfile q_values2 p_val using Q_valuesGP, replace //create .dta file named Q_valuesGP where p_values will be stored (p_val) to perform multiple hypothesis testing on treatment coefficients
	quietly reg travel_own Treatment i.district i.id_date i.jio_yn `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg W2total_interactions_vill  Treatment i.district i.id_date `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg typical_handwash Treatment i.district i.id_date  `controls', vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg resp_mask_wear Treatment i.district i.id_date `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg W2ever_talk Treatment i.district i.id_date  `controls' , vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	quietly reg net_knowledge Treatment i.district i.id_date  `controls', vce(cluster pincode)
		quietly test Treatment
		post q_values2 (r(p))
	postclose q_values2

	use Q_valuesGP, clear 	//open Q_values_tab1 to compute q_values
	qqvalue p_val, method(simes) qvalue(q) //compute q_values using Simes correction (equi. BH)
	   
	//Pooled q_values
	loc travel_qval : display %4.3f q[1]
	loc intrct_qval : display %4.3f q[2]
	loc handwash_qval : display %4.3f q[3]
	loc mask_qval : display %4.3f q[4]
	loc talk_qval : display %4.3f q[5]
	loc knowledge_qval : display %4.3f q[6]
	
	

frame change default 		//back to default frame




//Main Regressions
reg travel_own Treatment i.district i.id_date `controls' , vce(cluster pincode)
su travel_own if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_nonjio.tex", ///
keep(Treatment) replace ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`travel_qval'"  \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" ) ctitles("Variables","Did you travel outside your village?") statfont(normalsize) summstat(N)  summtitles("Observations")


reg W2total_interactions_vill  Treatment i.district i.id_date  `controls' , vce(cluster pincode)
su W2total_interactions_vill if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_nonjio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons sdec(3) nostars nolegend addrows("q-value", "`intrct_qval'"\ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" ) ctitles("Variables","Number of interactions with people within 2 arms length") statfont(normalsize) summstat(N)  summtitles("Observations")


reg typical_handwash Treatment i.district i.id_date `controls', vce(cluster pincode)
su typical_handwash if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_nonjio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`handwash_qval'"  \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" ) ctitles("Variables","Estimated \% time washing hands upon returning home") statfont(normalsize) summstat(N)  summtitles("Observations")

reg resp_mask_wear Treatment i.district i.id_date `controls' , vce(cluster pincode)
su resp_mask_wear if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_nonjio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons sdec(3) nostars nolegend addrows("q-value", "`mask_qval'" \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" ) ctitles("Variables","Did you use a mask?") statfont(normalsize) summstat(N)  summtitles("Observations")


reg W2ever_talk Treatment i.district i.id_date `controls' , vce(cluster pincode)
su W2ever_talk if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_nonjio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`talk_qval'"  \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" ) ctitles("Variables","Number of conversations in person /online /mobile about COVID-19") statfont(normalsize) summstat(N)  summtitles("Observations")

reg net_knowledge Treatment i.district i.id_date `controls', vce(cluster pincode)
su net_knowledge if e(sample) & T1 ==0 & T2 ==0 & T3 ==0 & T4 ==0 & T5 ==0 & T6 ==0 & T7 ==0 & T8 ==0
loc depvarmean : display %4.3f  `r(mean)'
outreg using "`path'/output/Tables/Table2_nonjio.tex", ///
keep(Treatment) merge ///
tex stats(b se p) nocons  sdec(3) nostars nolegend addrows("q-value", "`knowledge_qval'"  \ "District FE", "\checkmark"\ "Survey Day FE", "\checkmark" \"Control Mean", "`depvarmean'" ) ctitles("Variables","COVID-19 Knowledge Index") statfont(normalsize) summstat(N)  summtitles("Observations")


restore

frame drop MHT


****The regressions below give us pvals for difference between jio and non jio (last row of TableS16) ****

postfile q_values2 p_val using Q_values_tab1, replace //create .dta file named Q_values_tab1 where p_values will be stored (p_val) to perform multiple hypothesis testing on treatment coefficients

reg travel_own Treatment TrtXjio i.district#i.jio_yn i.id_date#i.jio_yn i.jio_yn smartphone#i.jio_yn  c.resp_age#i.jio_yn resp_gender#i.jio_yn , vce(cluster pincode)
estimates store travel
quietly test TrtXjio
post q_values2 (r(p))

reg W2total_interactions_vill Treatment TrtXjio i.district#i.jio_yn i.id_date#i.jio_yn i.jio_yn smartphone#i.jio_yn  c.resp_age#i.jio_yn resp_gender#i.jio_yn , vce(cluster pincode)
estimates store interactions
quietly test TrtXjio
post q_values2 (r(p))

reg typical_handwash Treatment TrtXjio i.district#i.jio_yn i.id_date#i.jio_yn i.jio_yn smartphone#i.jio_yn  c.resp_age#i.jio_yn resp_gender#i.jio_yn , vce(cluster pincode)
estimates store handwash
quietly test TrtXjio
post q_values2 (r(p))

reg resp_mask_wear Treatment TrtXjio i.district#i.jio_yn i.id_date#i.jio_yn i.jio_yn smartphone#i.jio_yn  c.resp_age#i.jio_yn resp_gender#i.jio_yn , vce(cluster pincode)
estimates store mask
quietly test TrtXjio
post q_values2 (r(p))

reg W2ever_talk Treatment TrtXjio i.district#i.jio_yn i.id_date#i.jio_yn i.jio_yn smartphone#i.jio_yn  c.resp_age#i.jio_yn resp_gender#i.jio_yn , vce(cluster pincode)
estimates store ever_talk
quietly test TrtXjio
post q_values2 (r(p))

reg net_knowledge Treatment TrtXjio i.district#i.jio_yn i.id_date#i.jio_yn i.jio_yn smartphone#i.jio_yn  c.resp_age#i.jio_yn resp_gender#i.jio_yn , vce(cluster pincode)
estimates store knowledge
quietly test TrtXjio
post q_values2 (r(p))


postclose q_values2

frame create MHT 				//create temporary frame to store q_values 
frame change MHT
	use Q_values_tab1, clear 	//open Q_values_tab1 to compute q_values
	qqvalue p_val, method(simes) qvalue(q) //compute q_values using simes correction (equiv. BH)
	loc travel_qval = q[1]
	loc intrct_qval = q[2]
	loc handwash_qval = q[3]
	loc mask_qval = q[4]
	loc talk_qval = q[5]
	loc knowledge_qval = q[6]
	
	
frame change default 		//back to default frame

outreg2 [travel] using "`path'/output/Tables/Table2_Ftest.tex", ///
keep(TrtXjio) replace ///
label tex(frag) stats(pval) bracket(pval) noaster noobs nonotes nor2 nocons dec(3) adec(3) addstat("q_value", `travel_qval') ///
ctitle(" ")

outreg2 [interactions] using "`path'/output/Tables/Table2_Ftest.tex", ///
keep(TrtXjio) append ///
label tex(frag) stats(pval) bracket(pval) noaster noobs nonotes nor2 nocons dec(3) adec(3) addstat("q_value", `intrct_qval') ///
ctitle(" ")

outreg2 [handwash] using "`path'/output/Tables/Table2_Ftest.tex", ///
keep(TrtXjio) append ///
label tex(frag) stats(pval) bracket(pval) noaster noobs nonotes nor2 nocons dec(3) adec(3) addstat("q_value", `handwash_qval') ///
ctitle(" ")

outreg2 [mask] using "`path'/output/Tables/Table2_Ftest.tex", ///
keep(TrtXjio) append ///
label tex(frag) stats(pval) bracket(pval) noaster noobs nonotes nor2 nocons dec(3) adec(3) addstat("q_value", `mask_qval') ///
ctitle(" ")

outreg2 [ever_talk] using "`path'/output/Tables/Table2_Ftest.tex", ///
keep(TrtXjio) append ///
label tex(frag) stats(pval) bracket(pval) noaster noobs nonotes nor2 nocons dec(3) adec(3) addstat("q_value", `talk_qval') ///
ctitle(" ")

outreg2 [knowledge] using "`path'/output/Tables/Table2_Ftest.tex", ///
keep(TrtXjio) append ///
label tex(frag) stats(pval) bracket(pval) noaster noobs nonotes nor2 nocons dec(3) adec(3) addstat("q_value", `knowledge_qval') ///
ctitle(" ")

frame drop MHT
erase "Q_valuesGP.dta"
erase "Q_values_tab1.dta"

**NOTE: q-values for the last column were entered manually and obtained from the following R-code:
* p_valFtest = c(0.016,0.179, 0.057) //inputing F-test values
* p.adjust(p=p_valFtest, method="BH")
****

*********END**********


